[ndata, text, alldata] = xlsread('DataIndex.xlsx');

fileID = fopen('log_get_data.txt','a');
fprintf(fileID,'----------START %s ----------',datestr(now));

for j = 249 : length(ndata)
%     security_id = get_info_from_database('sec_id', text{j,1});
%     if(~isnumeric(security_id))
%             continue;
%     end
    fprintf('----------Importing %d/%d , %s (%d) ...... ',j,length(ndata),text{j+1,1},ndata(j,1));
    offset = 2;
    type = 0;
    if(~isnan(ndata(j,10)))
        type=ndata(j,10);
    end
    status = get_data_to_excel(ndata(j,1),offset,text{j+1,1},type);
    if(status == -1)
        fprintf('\n----------Fail getting data. Try with offset 1\n');        
        status = get_data_to_excel(ndata(j,1),1,text{j+1,1},type);
        if(status == -1)
            fprintf('FAIL IMPORTING...\n');
            fprintf(fileID,'FAIL IMPORTING %s...\n',text{j+1,1});
        end        
    end            
        
    fprintf('\n----------DONE Importing----------\n');
    fprintf(fileID,'DONE Importing %d/%d , %s (%d) ...... \n',j,length(ndata),text{j+1,1},ndata(j,1));
end

fprintf(fileID,'----------END %s ----------',datestr(now));
fclose(fileID);